home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Readers / Gui4Cli / Docs / Tutorials / CutVar.gc < prev    next >
Text File  |  1997-12-02  |  2KB  |  92 lines

  1. G4C
  2. ;          xCutVar : CHAR and WORD are included, but not LINE
  3. ;                    CUT is included, but not COPY 
  4.  
  5. WINBIG -1 -1 498 189  "CutVar.gc"
  6. WinType 11110001
  7. usetopaz
  8.  
  9. ; ---- Decorations
  10. BOX 0 0 498 87  OUT RIDGE
  11. BOX 0 87 498 102  OUT RIDGE
  12.  
  13. ; ---- Embossed Headings using the user's screen font
  14. CTEXT 12 7  " Using CutVar on a word " #screen 8 2 0 0001
  15. CTEXT 10 93  " Using CutVar on a line "  #screen 8 2 0 0001
  16.  
  17. xonLoad 
  18. GuiOpen CutVar.gc
  19.  
  20. xonClose
  21. GuiQuit CutVar.gc
  22.  
  23. ; ---------------------------------- Upper half : cutting a word
  24.  
  25. TEXT 32 21 108 10  "Enter a word to be cut (and press <Return>) :" 48 NOBOX
  26.  
  27. XTEXTIN 32 32 216 13  '' word '' 100
  28.  
  29. TEXT 32 48 108 10  "Cut it after which letter?" 27 NOBOX
  30.  
  31.  
  32. ;  The number entered is used to mark the position to cut the word
  33.  
  34. XTEXTIN 378 46 54 13  'Enter a number' cutpos '' 100
  35. ;     Cut the first (or last) 'cutpos' letters from 'word'
  36. ;     and put them into 'dest'.
  37. ;     A negative value counts from the end of the word.
  38. ;     The CHAR argument determines that letters are counted.
  39. CutVar word CUT CHAR $cutpos dest
  40. ;     Show the two parts
  41. update CutVar.gc 1 $dest
  42. update CutVar.gc 2 $word
  43.  
  44. XBUTTON 383 60 43 10  'Tip'
  45. setvar a 'Enter SENSIBLE values for the cutting position.\n'
  46. appvar a 'Remember GIGO : Garbage in, garbage out.\n\n'
  47. appvar a 'Try entering a negative value for the cutting position.'
  48. ezreq $a 'Okay' v
  49.  
  50. ;     Gadgets to display the results
  51.  
  52. TEXT 32 58 108 10  "Your word has been cut into " 45 NOBOX
  53.  
  54. TEXT 32 69 162 13  " " 40 BOX
  55. gadid 1
  56.  
  57. TEXT 205 69 162 13  " " 40 BOX
  58. gadid 2
  59.  
  60. ;----------------------------------------- Lower half
  61. ;     Line cutting, more or less the same as word cutting above
  62.  
  63. TEXT 32 109 108 10  "Enter a line to be cut (and press <Return>) : " 48 NOBOX
  64.  
  65. XTEXTIN 32 120 400 13  '' line "" 200
  66.  
  67. TEXT 32 135 108 10  "Cut it after which word?" 27 NOBOX
  68.  
  69. XTEXTIN 378 133 54 13  'Enter a number' wcutpos '' 100
  70. ;     The WORD argument determines that words are counted.
  71. ;     Otherwise, as above.
  72. CutVar line CUT WORD $wcutpos dest2
  73. ;     The initial space needs to be cut from the second part of
  74. ;     the line.
  75. if $wcutpos > 0                ; Counting forwards
  76.   CutVar line CUT CHAR 1 trim
  77. else                           ; Counting from the end
  78.   CutVar dest2 CUT CHAR 1 trim
  79. endif
  80. update CutVar.gc 3 $dest2
  81. update CutVar.gc 4 $line
  82.  
  83.  
  84. TEXT 32 146 108 10  "Your line has been cut into " 45 NOBOX
  85.  
  86. TEXT 32 157 378 13  " " 100 BOX
  87. gadid 3
  88.  
  89. TEXT 32 171 378 13  " " 100 BOX
  90. gadid 4
  91.  
  92.